package com.ruoyi.supplier.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier.domain.TbBankOutcomeName;
import com.ruoyi.supplier.service.ITbBankOutcomeNameService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出账名目Controller
 * 
 * @author ruoyi
 * @date 2021-08-14
 */
@RestController
@RequestMapping("/supplier/bankOutcomeName")
public class TbBankOutcomeNameController extends BaseController
{
    @Autowired
    private ITbBankOutcomeNameService tbBankOutcomeNameService;

    /**
     * 查询出账名目列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankOutcomeName:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbBankOutcomeName tbBankOutcomeName)
    {
        startPage();
        List<TbBankOutcomeName> list = tbBankOutcomeNameService.selectTbBankOutcomeNameList(tbBankOutcomeName);
        return getDataTable(list);
    }

    /**
     * 导出出账名目列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankOutcomeName:export')")
    @Log(title = "出账名目", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbBankOutcomeName tbBankOutcomeName)
    {
        List<TbBankOutcomeName> list = tbBankOutcomeNameService.selectTbBankOutcomeNameList(tbBankOutcomeName);
        ExcelUtil<TbBankOutcomeName> util = new ExcelUtil<TbBankOutcomeName>(TbBankOutcomeName.class);
        return util.exportExcel(list, "出账名目数据");
    }

    /**
     * 获取出账名目详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankOutcomeName:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbBankOutcomeNameService.selectTbBankOutcomeNameById(id));
    }

    /**
     * 新增出账名目
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankOutcomeName:add')")
    @Log(title = "出账名目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbBankOutcomeName tbBankOutcomeName)
    {
        return toAjax(tbBankOutcomeNameService.insertTbBankOutcomeName(tbBankOutcomeName));
    }

    /**
     * 修改出账名目
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankOutcomeName:edit')")
    @Log(title = "出账名目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbBankOutcomeName tbBankOutcomeName)
    {
        return toAjax(tbBankOutcomeNameService.updateTbBankOutcomeName(tbBankOutcomeName));
    }

    /**
     * 删除出账名目
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankOutcomeName:remove')")
    @Log(title = "出账名目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbBankOutcomeNameService.deleteTbBankOutcomeNameByIds(ids));
    }
}
